# -*- coding: utf-8 -*-
# @Time    : 2021/3/19 10:24
# @Author  : xxue
# @Email   : x_xue1212@163.com
# @File    : 3.19 python流程控制.py
# @Software: PyCharm


#顺序结构
# import math
#
# a = int(input("a = "))
# b = int(input("b = "))
# c = int(input("c = "))
#
# #求取半边长
# p =(a+b+c)/2
#
# #求面积
# s=math.sqrt(p*(p-a)*(p-b)*(p-c))
# print("s=",s)


# if嵌套使用
# import math
#
# a = int(input("a = "))
# b = int(input("b = "))
# c = int(input("c = "))
# if a>0 and b>0 and c>0:
#     if a+b>c and b+c>a and a+c>b:
#         p = (a + b + c) / 2
#         s = math.sqrt(p * (p - a) * (p - b) * (p - c))
#         print("s=", s)
#     else:print("invalid")
# else:
#     print("invalid")

##if三元运算
# a = 10
# b = 20
# result = print("ture")if a>b else print("false")
# c = a if a>b else b

#接受从键盘的输入，如果接受的字符串中含有"hello",提示"hello"存在字符串中；反之，提示"hello"不存在字符串中
# str = input("请输入字符串：")
# result = print("hello存在字符串中") if "hello" in str else print("hello不存在字符串中") #1
# print("hello%s存在字符串中"%(''if "hello" in str else '不'))#2

#接受从键盘的输入，接受三个数，这三个数的范围在1-6之间，超出范围，输入不合法：合法，计算三数之和
# 如果三数之和>10,提示大；反之，提示小
# a = int(input("a = "))
# b = int(input("b = "))
# c = int(input("c = "))
# # for i in range(3):
# #
#
# if 1<a<6 and 1<b<6 and 1<c<6:
#     sum = a+b+c
#     result = print("和大")if sum>10 else print("和小")
# else:
#     print("invalid")

# 练习
#
# for i in range(3):
#     username = input("请输入用户名：")
#     password = input("请输入密码：")
#     if username=="root"and password=="123456":
#         print("登录成功")
#         break
#     elif i>=2:
#         print("登陆失败")
#     else:
#         print(f"还有{2-i}次尝试机会")






# print("登录成功")if username=="root"and password=="123456" else print("登录失败")


# str = input("请输入一个字符串:")
# # for i in 'aNsoIw':
# result = ""
# for i in str:
    # print(i)
    # if i.isupper():
    #     result+="1"
    # else:
    #     result+="0"

    # print("1",end='') if i.isupper() else print("0",end='')

# 练习------猜数字
import random
a=random.randint(0,100)
for i in range(3):
    num = input("请输入数字：")
    if num.isdigit():
        if int(num) == a:
            print("猜对啦")
            break
        elif i>=2:
            print("输入错误")
        else:
            print("大") if int(num)>a else print("小")
            print(f"你还有{2-i}次机会")
print(f"a={a}")







